import request from '@/axios'
import type { TableData } from './types'
import fileRequest from "@/axios/fileRequest"
// export const getTableListApi = (params: any) => {
//   return request.get({ url: '/mock/example/list', params })
// }

export const getTableListApi = (params: any) => {
  return request.get({ url: '/zzmapi/user/getUserList', params })
}

export const getUserList = (params: any) => {
  return request.get({ url: '/zzmapi/user/getUserList', params })
}

export const getClassListApi = (params: any) => {
  return request.get({ url: '/zzmapi/user/getClassName', params })
}
// addClass
export const addClass = (params: string[]): Promise<IResponse> => {
  return request.post({ url: '/zzmapi/user/addClass', data: params })
}
// editClass
export const editClass = (params: string[]): Promise<IResponse> => {
  return request.post({ url: '/zzmapi/user/editClass', data: params })
}
// delClass
export const delClass = (params: any) => {
  return request.get({ url: '/zzmapi/user/delClass', params:{cid:params} })
}
export const getCardTableListApi = (params: any) => {
  return request.get({ url: '/mock/card/list', params })
}

export const getTreeTableListApi = (params: any) => {
  return request.get({ url: '/mock/example/treeList', params })
}

export const saveTableApi = (data: Partial<TableData>): Promise<IResponse> => {
  return request.post({ url: '/mock/example/save', data })
}

export const getTableDetApi = (id: string): Promise<IResponse<TableData>> => {
  return request.get({ url: '/mock/example/detail', params: { id } })
}

export const delTableListApi = (ids: string[] | number[]): Promise<IResponse> => {
  return request.post({ url: '/mock/example/delete', data: { ids } })
}

export const addUser = (params: string[]): Promise<IResponse> => {
  return request.post({ url: '/zzmapi/user/register', data: params })
}
// http://www.9lele.com/public/index.php/api/user/register
// editUser

export const editUser = (params: string[]): Promise<IResponse> => {
  return request.post({ url: '/zzmapi/user/editUser', data: params })
}

// delUser
export const delUser = (id: string): Promise<IResponse<TableData>> => {
  return request.get({ url: '/zzmapi/user/delUser', params: { id } })
}

export const getClassCount = (cid: string): Promise<IResponse<TableData>> => {
  return request.get({ url: '/zzmapi/user/getClassCount', params: { cid } })
}
// 获取面试列表
export const getCompanyList = (params: object): Promise<IResponse<TableData>> => {
  return request.get({ url: '/zzmapi/user/getCompany', params: params })
}

export const addCompany = (params: object): Promise<IResponse<TableData>> => {
  return request.post({ url: '/zzmapi/user/addCompany', data: params })
}
export const editCompany = (params: object): Promise<IResponse<TableData>> => {
  return request.post({ url: '/zzmapi/user/editCompany', data: params })
}

export const uploadFile = (File:File): Promise<IResponse<TableData>> => {
  const formData = new FormData()
  formData.append('file',File)

  return fileRequest.post('/zzmapi/user/upload', formData )
}